package com.atguigu.gmall.cart.controller;

import com.atguigu.gmall.cart.service.CartInfoService;
import com.atguigu.gmall.model.cart.CartInfo;
import com.atguigu.gmall.model.product.SkuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//购物车管理
@RestController
@RequestMapping("api/cart")
public class CartApiController {
    @Autowired
    private CartInfoService cartInfoService;

    //加入购物车
    @PostMapping("/addCart/{skuId}/{skuNum}")
    public CartInfo addCart(@PathVariable Long skuId, @PathVariable Integer skuNum){
        return  cartInfoService.addCart(skuId,skuNum);

    }

    //查询新添加的购物车商品
    @PostMapping("/toCart/{skuId}")
    public CartInfo toCart(@PathVariable Long skuId){
        return  cartInfoService.toCart(skuId);

    }
}
